#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

char *newnew = (char*)"myVAL=07210721";

int main()
{
    printf("我的程序要运行了！\n");
    if(fork() == 0)
    {
        printf("I am child~ My Pid Is: %d\n", getpid());
        sleep(1);
        char *const argv[] = {
            (char*const)"other",
            (char*const)"-a",
            (char*const)"-b",
            (char*const)"-c",
            (char*const)"-d",
            NULL
        };
        char *const env[] = {
            (char *const)"MYVAL=07210721",
            NULL
        };
        putenv(newnew);
        execvp("./other", argv);
        //execvpe("./other", argv, env);
        //execvp(argv[0], argv);
        //execv("/usr/bin/ls", argv);
        //execlp("/usr/bin/ls", "ls", "-l", "-a", NULL);
        exit(1);
    }
    waitpid(-1, NULL, 0);
    printf("我的程序运行完了！\n");
    exit(1);
}


//int main()
//{
//    printf("我的程序要运行了！\n");
//    if(fork() == 0)
//    {
//        printf("I am child~ My Pid Is: %d\n", getpid());
//        sleep(1);
//        // int n = execl("/usr/bin/ls", "ls", "-l", "-a", NULL);
//        execl("./other", "other", NULL);
//        exit(1);
//    }
//    waitpid(-1, NULL, 0);
//
//
//    //execl("user/bin/top", "top", NULL);
//    printf("我的程序运行完了！\n");
//    exit(1);
//    //return 0;
//}






